# 支持向量机

from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import SGDClassifier
from sklearn.metrics import classification_report
import load_data

x_train, y_train, x_test, y_test = load_data.load()

ss = StandardScaler()
x_train = ss.fit_transform(x_train)
x_test = ss.transform(x_test)

sgdc = SGDClassifier()
sgdc.fit(x_train, y_train)
y_test_predict = sgdc.predict(x_test)
y_train_predict = sgdc.predict(x_train)

print('Test Dataset Accruacy of SGD Classifier:', sgdc.score(x_test, y_test))
print(classification_report(y_test, y_test_predict, target_names=['group1', 'group2', 'group3']))

print('Train Dataset Accruacy of SGD Classifier:', sgdc.score(x_train, y_train))
print(classification_report(y_train, y_train_predict, target_names=['group1', 'group2', 'group3']))
